﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace VirtualVisionSpace
{

    public class PointEnvironment : EnvironmentBase
    {
        Rectangle[] rects = new Rectangle[20];
        Brush[] brushes = new Brush[20];
        Size rect = new Size(10, 10);
        public PointEnvironment(Size size)
            : base(size)
        {
            for (int i = 0; i < rects.Length; i++)
            {
                rects[i] = new Rectangle(random.Next(size.Width - rect.Width), random.Next(size.Height - rect.Height), random.Next(rect.Width), random.Next(rect.Height));
                int value = random.Next(256);
                brushes[i] = new SolidBrush(Color.FromArgb(value, value, value));
            }
        }
        protected override void OnEnvironmentChanged(System.Drawing.Bitmap environment)
        {
            Graphics G = Graphics.FromImage(environment);
            G.Clear(Color.Black);
            for (int i = 0; i < rects.Length; i++)
            {
                //G.FillRectangle(Brushes.White, rects[i]);
                G.FillEllipse(brushes[i], rects[i]);
                if (i % 2 == 0)
                {
                    rects[i].Offset(1, 1);
                    rects[i].X %= this.size.Width - rect.Width;
                    rects[i].Y %= this.size.Height - rect.Height;
                }
            }
            G.Dispose();
        }
    }
}
